const http = require('http')
const fs = require('fs')
let index = fs.readFileSync('./public/index.html','utf-8')
let admin = fs.readFileSync('./public/admin.html','utf-8')
console.log(index);
console.log(admin);
const app = http.createServer((req,res)=>{
    res.setHeader('content-type','text/html;charset=utf-8')
    let u = new URL(req.url,'https://127.0.0.1:80')
    if(u.pathname === '/index.html'){
        res.end(index)
    }
    else if (u.pathname === '/admin.html'){
        res.end(admin)
    }
    else if(u.pathname === '/'){
        res.end(index)
    }
    else{
        res.end('路径错误')
    }
})
app.listen(80,()=>{
    console.log('端口80已启动');
})